package com.fxu.mq.producer;

import com.fxu.framework.mq.redis.simple.RedisMqTemplate;
import com.fxu.mq.message.RedisSimpleMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Sms 短信相关消息的 Producer
 *
 * @author fangxu
 * @version 2022-01-07
 */
@Slf4j
@Component
public class RedisSimpleProducer {

    @Resource
    private RedisMqTemplate redisMQTemplate;

    /**
     * 发送 {@link RedisSimpleMessage} 消息
     *
     * @param logId 短信日志编号
     * @param mobile 手机号
     * @param channelId 渠道编号
     * @param apiTemplateId 短信模板编号
     * @param templateParams 短信模板参数
     */
    public void sendSmsSendMessage(Long logId, String mobile,
                                       Long channelId, String apiTemplateId,
                                       List<Map<String, Object>> templateParams) {
        RedisSimpleMessage message = new RedisSimpleMessage();
        message.setLogId(logId);
        message.setMobile(mobile);
        message.setChannelId(channelId);
        message.setApiTemplateId(apiTemplateId);
        message.setTemplateParams(templateParams);
        redisMQTemplate.send(message);
    }

}
